/*
 * Copyright (c) 2014 jbing.org
 */
package jbing.log;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.util.Properties;

/**
 * jbing.log.Log
 * 
 * @author 旧城(jbing.org@gmail.com)
 * @date 2014/03/19
 * @version 0.0.2
 */
public class LogFactory {
	private static Properties prop;
	static{
		prop = new Properties();
		InputStream is = LogFactory.class.getClassLoader().getResourceAsStream("jbing.log.properties");
		try {
			if(is != null){
				prop.load(is);
			}else{
				prop = null;
				System.err.println("classPath:jbing.log.properties NOT FOUND");
			}
		} catch (IOException e) {
		}
	}
	public static Log getLog(Class<?> clazz){
		try {
			if(prop != null){
				Constructor<LogHPropSupport> lhpsC = (LogHPropSupport.class).getDeclaredConstructor();
				lhpsC.setAccessible(true);
				LogHPropSupport lhps = lhpsC.newInstance();
				lhps.setClazz(clazz);
				lhps.setProp(prop);
				return lhps;
			}else{
				Constructor<LogNPropSupport> lnps = (LogNPropSupport.class).getDeclaredConstructor();
				lnps.setAccessible(true);
				return lnps.newInstance();
			}
		} catch (Exception e) {
		}
		return null;
	}
}
